package com.program.facesigninsystem.dao;

import com.program.facesigninsystem.entity.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface IUserInfoDao {
    /****
     * 登录
     * @param openid
     * @return
     */
    UserInfo loginUser(@Param("openid") String openid);

    /****
     * 为用户添加token
     * @param uid
     * @param token
     */
    void  updateToken(@Param("uid")String uid,@Param("token")String token);

    /***
     * 更新头像
     * @param uid
     * @param avatar
     */
    void updateAvatar(@Param("uid")String uid,@Param("avatar")String avatar,@Param("alias")String alias);

    /****
     * 添加新用户
     * @param uid
     * @param openid
     * @param token
     */
    void addUser(@Param("uid")String uid,@Param("openid")String openid,@Param("token")String token,@Param("userAvatar") String userAvatar,@Param("uid1")String uid1,@Param("userAlias") String userAlias);

    /****
     * 更新用户信息
     * @param uid
     * @param name
     * @param type
     * @param major
     * @param uclass
     * @param university
     * @param academy
     * @param avatar
     * @param sex
     * @param age
     * @param address
     * @param phone
     * @param email
     */
    void updateUser(@Param("uid")String uid,@Param("name")String name,@Param("type")int type,@Param("major")String major,
                    @Param("uclass")String uclass,@Param("university")String university,@Param("academy")String academy,
                    @Param("avatar")String avatar,@Param("sex")String sex,@Param("age")int age,
                    @Param("address")String address,@Param("phone")String phone,@Param("email")String email);

    /****
     * 返回用户信息
     * @param uid
     * @return
     */
    Map<String,Object> selectUser(@Param("uid")String uid);

    /***
     * 注册人脸
     * @param uid
     * @param facefeature
     */
    void addFace(@Param("uid")String uid,@Param("facefeature")byte[] facefeature,@Param("createTime") String createTime);

    /***
     * 查询人脸特征
     * @param uid
     * @return
     */
    Object selectFaceFeature(@Param("uid")String uid);


    /***
     * 查询某名单多张人脸
     * @param cid
     * @return
     */
    List<Map<String,Object>> selectFaceFeatures(@Param("cid")String cid);

    /***
     * 管理员登录
     * @param user
     * @param password
     * @return
     */
    Object selectAdmin(@Param("user")String user,@Param("password")String password);

    /***
     * 更新管理员token
     * @param user
     * @param token
     */
    void adminToken(@Param("user")String user,@Param("token")String token);

    /***
     * 修改用户类型（切换身份）
     * @param uid
     * @param type
     */
    void updateUserType(@Param("uid")String uid,@Param("type")int type);

    /****
     * 查询签到发起人（学校、学院、姓名）
     * @param university
     * @param academy
     * @param name
     * @return
     */
    List<Map<String,Object>> selectList(@Param("name")String name,@Param("university")String university, @Param("academy")String academy);

    /***
     * 更新issued
     * @param uid
     */
    void updateIssued(@Param("uid")String uid);

    void addTempList(@Param("lid")String lid,@Param("uid")String uid);

    List<Map<String,String>> selectTempList(@Param("lid")String lid);

    void deleteTempList(@Param("lid")String lid);

    String selectFaceInfo(@Param("uid")String uid);

    UserInfo selectByUid1(@Param("uid1")String uid1);

    void updatePassword(@Param("uid1")String uid1,@Param("password")String password,@Param("salt")String salt);

    Map<String,Object> selectU(@Param("uid1")String uid1);

    void updateBindId(@Param("uid")String uid,@Param("bindId")int bindId);

    void updateIsExamine(@Param("uid")String uid,@Param("isExamine")int isExamine);

    void updateRoleId1(@Param("uid")String uid,@Param("roleId")int roleId);

    List<UserInfo> selectUnExamine();

    void updateRoleId(@Param("bindid")int bindid,@Param("roleid")int roleid);

    UserInfo selectByBindid(@Param("bindid")int bindid);

    Map<String,Object> selectExamine(@Param("uid")String uid);

    String selectAvatar(@Param("uid")String uid);

    String selectCreateTime(@Param("uid")String uid);

    void updateCreateTime(@Param("uid")String uid,@Param("facefeature")byte[] facefeature,@Param("createTime") String createTime);
}
